package com.example.anju.controller;

import com.example.anju.entity.Person;
import com.example.anju.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author CoderXshuai
 * @date 2021/7/5/0005 11:02
 */
@Controller
@RequestMapping("/person")
@ResponseBody
public class PersonController {
    @Autowired
    PersonService personService;

    /**
     * 获取所有
     *
     * @return 所有人员列表
     */
    @RequestMapping("all")
    List<Person> getAll() {
        return personService.getAll();
    }

    @PostMapping("update")
    /**
     * 更新人员信息
     *
     * @param newPerson 新人员信息
     */
    void updatePerson(@RequestBody Person newPerson) {
        personService.updatePerson(newPerson);
    }
}
